<!DOCTYPE html>
<html>
    <head>
        <title>work</title>
        <meta charset="UTF-8" />
        <link rel="stylesheet" type="text/css" href="_assert/css/common.css"/>
        <link rel="stylesheet" href="_assert/css/select.css" />
    </head>
    <body>
          <div class="header">
            <div class="container"><img src="_assert/img/header.png" /></div>
        </div>
        <div class="sfjsq">
            <div class="container">
            <form name="sfjsq">
                <div class="warpper">
                    <div class="left">
                        <div>房屋类别：</div>
                    </div>
                    <div class="right">
                        <div id="fwle"><select>
                            <option value="0"  selected>二手房</option>
                            <option  value="1">新房</option>
                        </select></div>
                    </div>
                </div>
              
                <div class="warpper">
                    <div class="left">
                        <div>房屋面积：</div>
                    </div>
                    <div class="right">
                        <div class="r1">
                            <div class="t1"><input type="text" id="fwmj" /></div>
                            <div class="t2">m2</div>
                            <div class="t3"></div>
                        </div>
                    </div>
                </div>
                 <div class="warpper">
                    <div class="left">
                        <div>房屋单价：</div>
                    </div>
                    <div class="right">
                        <div class="r1">
                            <div class="t1"><input type="text" id="fwdj" /></div>
                            <div class="t2">元/m2</div>
                            <div class="t3"></div>
                        </div>
                    </div>
                </div>
                 <div class="warpper">
                    <div class="left">
                        <div>房屋总价：</div>
                    </div>
                    <div class="right">
                        <div class="r1">
                            <div class="t1"><input type="text" id="fwzj"/></div>
                            <div class="t2">元</div>
                            <div class="t3"></div>
                        </div>
                    </div>
                </div>
                <div class="warpper">
                    <div class="left">
                        <div>计征方式：</div>
                    </div>
                    <div class="right">
                        <div id="jzfs"><select>
                            <option value="0" selected>房屋总价</option>
                            <option value="1" >房屋差价</option>
                        </select></div>
                    </div>
                </div>
                 <div class="warpper fwcj hidden">
                    <div class="left">
                        <div>房屋差价：</div>
                    </div>
                    <div class="right">
                        <div class="r1">
                            <div class="t1"><input type="text" id="fwzj"/></div>
                            <div class="t2">元</div>
                            <div class="t3"></div>
                        </div>
                    </div>
                </div>
                <div class="warpper">
                    <div class="left">
                        <div>房屋性质：</div>
                    </div>
                    <div class="right">
                        <div id="fwxz"><select>
                            <option value="0" selected>普通住宅</option>
                            <option value="1" >非普通住宅</option>
                            <option value="2" >经济适用房</option>
                        </select></div>
                    </div>
                </div>
                <div class="warpper">
                    <div class="left">
                        <div>购买年限：</div>
                    </div>
                    <div class="right">
                        <div id="gmnx"><select>
                            <option value="0" selected>两年以下</option>
                            <option value="1" >2-5年</option>
                            <option value"=2"  >5年以上</option>
                            <option  >新房</option>
                        </select></div>
                    </div>
                </div>
                <div class="warpper">
                    <div class="left">
                        <div>买房家庭首次购房：</div>
                    </div>
                    <div class="right">
                        <div id="scmf"><select>
                            <option  value="0" selected>是</option>
                            <option value="1"  >否</option>
                        </select></div>
                    </div>
                </div>
                <div class="warpper">
                    <div class="left">
                        <div>卖房家庭唯一住房：</div>
                    </div>
                    <div class="right">
                        <div id="wyzf" ><select>
                            <option value="0" selected>是</option>
                            <option value="1" >否</option>
                        </select></div>
                    </div>
                </div>
                <div class="warpper bd">
                    <div class="bd"><button type="button">开始计算</button></div>
                </div>
            </form>
            </div>
            
        </div>
        <script type="text/javascript" src="_assert/js/jquery-1.11.2.min.js"></script>
        <script type="text/javascript" src="_assert/js/jquery.select.js"></script>
    <script type="text/javascript">
	    $("#fwmj,#fwdj").change(function(){
	    	if($("#fwmj").val()!=""&&$("#fwdj").val()!=""){
	    		$("#fwzj").val(FixTwo(eval($("#fwmj").val()*$("#fwdj").val())));
	    	}
	    });
	    $("#jzfs select").change(function(){
	    	console.log($(".warpper.fwcj"));
	    	if($(this).val()==0){
	    		$(".warpper.fwcj").hide();
	    	}else{
	    		$(".warpper.fwcj").show();
	    	}
	    });
	    
	    $("#fwle select").change(function(){
	    	if($(this).val()=="1"){
	    		$(".warpper:gt(2)").hide();
	    		$(".warpper.bd").show();
	    	}
	    	else{
	    		$(".warpper:gt(2)").show();
	    		if($("#jzfs select").val()==0){
	    		$(".warpper.fwcj").hide();
	    	}else{
	    		$(".warpper.fwcj").show();
	    	}
	    	}
	    });
       $(".sfjsq button").click(function(){
       		var loactionF=true;
				/*判断计算器的输入值**/
				console.log($("input[type='text']:visible"));
				$("input[type='text']:visible").each(function(i,n){
					if(!$.isNumeric($(n).val())){
						alert("输入框的值不能为空，且必须为数字");
						loactionF=false;
						return false;
					}
				});
				
			var fwle=$(".sfjsq #fwle select").val();
			var fwmj=$(".sfjsq #fwmj").val();
			var fwdj=$(".sfjsq #fwdj").val();
			var fwzj=$(".sfjsq #fwzj").val();
			var fwxz=$(".sfjsq #fwxz select").val();
			var fwcj=$(".sfjsq #fwcj select").val();
			var gmnx=$(".sfjsq #gmnx select").val();
			var scmf=$(".sfjsq #scmf select").val();
			var wyzf=$(".sfjsq #wyzf select").val();
			localStorage.fwqs=sfNum(fwmj,fwzj,fwle,fwxz,scmf);
			console.log(localStorage.fwqs);
			localStorage.fwyys=yys(fwmj,gmnx,fwle,fwxz,fwzj);
			console.log(localStorage.fwyys);
			localStorage.grsdf=gsNum(fwzj,fwle,wyzf,gmnx);
			console.log(localStorage.grsdf);
			if(fwle==0){
				localStorage.flag="0";
				localStorage.gbyhs=5;
				localStorage.yhs=0;
				localStorage.zhdj=0;
			}
			else{
				localStorage.flag="1";
				localStorage.ggf=FixTwo(eval(fwmj*fwdj*0.003));
				console.log(localStorage.ggf);
				localStorage.cqsxf=FixTwo(eval(fwmj*fwdj*0.003));
				localStorage.yhs=FixTwo(eval(fwmj*fwdj*0.0005));
				if(eval(fwmj)>120){
					localStorage.sxf=1500;
				}else{
					localStorage.sxf=500;
				}
			}
			if(loactionF==false) return;
			location.href="shuifeiijisuanjieguo.html";
		});
		function sfNum(area,totalMoney,isNew,fwxz,scmf){
			if(isNew=="1"){
				if(eval(area<=90))
					return (FixTwo(eval(totalMoney*0.01)));
				if(eval(area>90)&&eval(area<144))
					return (FixTwo(eval(totalMoney*0.015)));
				if(eval(area>=144))
				return (FixTwo(eval(totalMoney*0.03)));
			};
			if(fwxz==1){
				return (FixTwo(eval(totalMoney*0.03)));
			}
			else{
				
				if(eval(area<=90)){
					if(scmf=="0"){
						return (FixTwo(eval(totalMoney*0.01)));
					}else{
						return (FixTwo(eval(totalMoney*0.03)));
					}
					
					
				}
				if(eval(area>90)&&eval(area<144)){
					if(scmf=="0"){
						return (FixTwo(eval(totalMoney*0.015)));
					}else{
						return (FixTwo(eval(totalMoney*0.03)));
					}
					
				}
				else{
					return (FixTwo(eval(totalMoney*0.03)));
				}
			}
		};
		function　yys(area,gmnx,isNew,fwxz,fwzj){
			if(isNew==0){
				
				if(gmnx!="0"&&fwxz!="1"&&eval(area<140)){
					return 0;
				}else{
					return (FixTwo(eval(fwzj*0.056)));
				}
				
			}else{
				return 0;
			}
		};
		function gsNum(totalMoney,isNew,wyzf,gmnx){
			console.log("gmnx");
			if(wyzf=="0"&&gmnx=="2"){
				return 0;
			}
			if(isNew=="1"){
				
			}
			else{
				return (FixTwo(eval(totalMoney*0.01)));
			}
			
		};
		
		  function FixTwo(n){
       	n=n+"";
       	if(n.indexOf(".")==-1)
       	return n;
       	n=eval((n-0)+0.004);
       return(Math.round(n*100)/100);
      };
    </script>
    </body>
</html>